<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
<![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8">
<![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9">
<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <title>创建随机性能数据</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
</head>
<body>

<textarea id="txt" style="width: 100%; height: 500px"></textarea>

<script>

/*
	吞吐量: request
	响应时间: responseTime
	流量: tx+rx
	当前连接: connections
	并发连接: conncurentConnectsions
	并发用户: conncurentUsers
	交易量: request
	成功率: successRate
	错误: error
*/
function createPerformances2ByResource(resourceId){
	var dataLen = 61;
	var arr = [];
	var now = new Date(2014, 9, 1, 12, 0, 0);
	while(dataLen-- > 1){
		arr.push({
			"timestamp": (new Date(+now).setMinutes(now.getMinutes()-dataLen)),
			"status": Math.random() < 0.5 ? 0 : parseInt(Math.random()*3),
			"system/throughput/total": parseInt(Math.random()*500),
			"system/error/app_error": parseInt(Math.random()*40),
			"system/error/failure_rate": parseInt(Math.random()*100),
			"system/response_time/avg": parseInt(Math.random()*100),
			"system/user/unique": parseInt(Math.random()*200),
			"system/score/apdex": parseInt(Math.random()*100)
		});
	}
	return arr;
}

function createPerformances2(){
	var obj = {};
	var resourceIds = ["app1", "app1-node11", "app1-node20", "app1-node31", "app1-node40"];
	resourceIds.forEach(function(resourceId){
		obj[resourceId] = createPerformances2ByResource(resourceId);
	});
	return obj;
}

//document.getElementById("txt").value = JSON.stringify(data, null, "	");
document.getElementById("txt").value = JSON.stringify(createPerformances2(), null, "	");
</script>
</body>
</html>